#!/usr/bin/env python
#coding=utf-8

from apscheduler.schedulers.blocking import BlockingScheduler
f

import logging
import Logger_Class
import time


logger = Logger_Class.Logger_test(logname='D:/log3.txt', loglevel='1', logger="Timer").getlog()
def my_job():
    print('hello world')

def setTime(function,seconds,args):

    logger.debug('使用scheduler模块设置自动任务的时间')
    scheduler = BlockingScheduler()#阻塞方式
    #scheduler = BackgroundScheduler()
    #trigger = IntervalTrigger(seconds=1)
    #scheduler.add_job(function, 'interval', trigger)

    scheduler.add_job(function, 'interval', seconds=seconds,args=args)
    #scheduler.add_job(function, 'cron', second='*/5')
    '''
    # 表示2017年3月22日17时19分07秒执行该程序
    
    sched.add_job(my_job, 'cron', year=2017, month=03, day=22, hour=17, minute=19, second=07)
    
    # 表示任务在6,7,8,11,12月份的第三个星期五的00:00,01:00,02:00,03:00 执行该程序
    
    sched.add_job(my_job, 'cron', month='6-8,11-12', day='3rd fri', hour='0-3')
    
    # 表示从星期一到星期五5:30（AM）直到2014-05-30 00:00:00
    
    sched.add_job(my_job(), 'cron', day_of_week='mon-fri', hour=5, minute=30, end_date='2014-05-30')
    
    # 表示每5秒执行该程序一次，相当于interval 间隔调度中seconds = 5
    
    sched.add_job(my_job, 'cron', second='*/5')'''

    scheduler.start()

